#include "../Require/Init.iss"
function main()
{
	extension -require isxeq2
	EA "Loading" "Idle.iss"
	if !${Me.InCombat} && !${Target(exists)} && ${NextTarget} == 0
	{
		VirtualState:Set[IDLE]
		while !${Me.InCombat} && ${VirtualState.Equal[IDLE]} && ${NextTarget} == 0
		{
			if ${Math.Distance[${Me.X}, ${Me.Z}, ${WanderX}, ${WanderZ}]} > 200.000000
			{
				EA "Wandering Too Far" "${WanderX}, ${WanderZ}"
				call MoveToMelee ${WanderX} ${WanderZ}
			}
			else
			{
				switch ${NextPoint}
				{
					case 1
						if ${NextPosition.Equal[ASC]}
						{
							NextPoint:Set[2]
						}
						else
						{
							NextPosition:Set[ASC]
							NextPoint:Set[2]
						}
						NextPointX:Set[${FirstPointX}]
						NextPointZ:Set[${FirstPointZ}]
					break
					case 2
						if ${NextPosition.Equal[ASC]}
						{
							NextPoint:Set[3]
						}
						else
						{
							NextPoint:Set[1]
						}
						NextPointX:Set[${SecondPointX}]
						NextPointZ:Set[${SecondPointZ}]
					break
					case 3
						if ${NextPosition.Equal[ASC]}
						{
							NextPoint:Set[4]
						}
						else
						{
							NextPoint:Set[2]
						}
						NextPointX:Set[${ThirdPointX}]
						NextPointZ:Set[${ThirdPointZ}]
					break
					case 4
						if ${NextPosition.Equal[ASC]}
						{
							NextPoint:Set[3]
						}
						else
						{
							NextPoint:Set[3]
							NextPosition:Set[DESC]
						}
						NextPointX:Set[${LastPointX}]
						NextPointZ:Set[${LastPointZ}]
					break
				}
				call MoveToMelee ${NextPointX} ${NextPointZ}
				if !${MadePosition}
				{
					FirstPointX:Set[${Script.ExecuteAtom[addSubtract, ${Me.X}, ${Math.Rand[50]:Inc[50]}]}]
					FirstPointZ:Set[${Script.ExecuteAtom[addSubtract, ${Me.Z}, ${Math.Rand[50]:Inc[50]}]}]
					SecondPointX:Set[${Script.ExecuteAtom[addSubtract, ${Me.X}, ${Math.Rand[40]:Inc[40]}]}]
					SecondPointZ:Set[${Script.ExecuteAtom[addSubtract, ${Me.Z}, ${Math.Rand[10]:Inc[10]}]}]
					ThirdPointX:Set[${Script.ExecuteAtom[addSubtract, ${Me.X}, ${Math.Rand[10]:Inc[10]}]}]
					ThirdPointZ:Set[${Script.ExecuteAtom[addSubtract, ${Me.Z}, ${Math.Rand[60]:Inc[60]}]}]
					LastPointX:Set[${Script.ExecuteAtom[addSubtract, ${Me.X}, ${Math.Rand[60]:Inc[60]}]}]
					LastPointZ:Set[${Script.ExecuteAtom[addSubtract, ${Me.Z}, ${Math.Rand[30]:Inc[30]}]}]
				}
			}
		}
	}
}
function atexit()
{
	VirtualState:Set[ROAM]
	EA "Unloading" "Idle.iss"
}
atom(script):int addSubtract(int var1, int var2)
{
	
	if ${Math.Rand[10]} < 5
	{
		RETURN ${Math.Calc[${var1}+${var2}]}
	}
	else
	{
		RETURN ${Math.Calc[${var1}-${var2}]}
	}
}